﻿using System;
using System.Linq;
using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[RequireComponent(typeof(Dropdown))]
public class UIResolutionDropdown : MonoBehaviour
{
    [CompilerGenerated]
    private static Func<Resolution, string> <>f__am$cache1;
    [CompilerGenerated]
    private static UnityAction<int> <>f__am$cache2;
    private Dropdown dropdown;
    private const string heightKey = "Screenmanager Resolution Height";
    private const string widthKey = "Screenmanager Resolution Width";

    private void Awake()
    {
        <Awake>c__AnonStorey76 storey = new <Awake>c__AnonStorey76();
        this.dropdown = base.GetComponent<Dropdown>();
        if (<>f__am$cache1 == null)
        {
            <>f__am$cache1 = x => string.Format("{0} x {1}", x.width, x.height);
        }
        this.dropdown.AddOptions(Screen.resolutions.Select<Resolution, string>(<>f__am$cache1).ToList<string>());
        storey.width = PlayerPrefs.GetInt("Screenmanager Resolution Width");
        storey.height = PlayerPrefs.GetInt("Screenmanager Resolution Height");
        this.dropdown.value = Screen.resolutions.ToList<Resolution>().FindIndex(new Predicate<Resolution>(storey.<>m__135));
        if (<>f__am$cache2 == null)
        {
            <>f__am$cache2 = delegate (int v) {
                Resolution resolution = Screen.resolutions.ElementAt<Resolution>(v);
                Screen.SetResolution(resolution.width, resolution.height, Screen.fullScreen);
            };
        }
        this.dropdown.onValueChanged.AddListener(<>f__am$cache2);
    }

    [CompilerGenerated]
    private sealed class <Awake>c__AnonStorey76
    {
        internal int height;
        internal int width;

        internal bool <>m__135(Resolution x)
        {
            return ((x.width == this.width) && (x.height == this.height));
        }
    }
}

